package main.java.com.amanda.utils;

import edu.princeton.cs.algs4.StdOut;
import java.util.Scanner;

/**
 * @author amanda
 * @Description 测试
 */

public class Count {
    private Count() {
    }
    public static void main(String[] args) {

        char[] chs = new char[100];
        String str;
        Scanner sc = new Scanner(System.in);
        StdOut.println("请输入字符串：");
        str = sc.nextLine();
        for (int i = 0; i < str.length(); i ++) {
            chs[i] = str.charAt(i);
        }

        Alphabet alphabet = new Alphabet("ABCDR");
        final int R = alphabet.radix();
        int[] count = new int[R];
        for (int i = 0; i < chs.length; i++) {
            char c = chs[i];
            if (alphabet.contains(c))
                count[alphabet.toIndex(c)]++;
        }
        for (int c = 0; c < R; c++)
            StdOut.println(alphabet.toChar(c) + " " + count[c]);
    }
}
/*
ABRACADABRA!
 */